<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
//1
console.log('1');     // 同步 
//2
setTimeout(function() {    //异步
    console.log('2');
    process.nextTick(function() {
        console.log('3');
    })
    new Promise(function(resolve) {
        console.log('4');
        resolve();
    }).then(function() {
        console.log('5')
    })
})
//3
process.nextTick(function() {   //异步  微任务
    console.log('6');
})

//4

new Promise(function(resolve) {    //同步  
    console.log('7');
    resolve();
}).then(function() {    //异步 微任务
    console.log('8')
})
//5
setTimeout(function() {     //异步
    console.log('9');
    process.nextTick(function() {
        console.log('10');
    })
    new Promise(function(resolve) {
        console.log('11');
        resolve();
    }).then(function() {
        console.log('12')
    })
})

// 1 7  6  8 2 4 3 5 9  11 10 12

</script>
</html>